import React from 'react';
import ReactDOM from 'react-dom';

import { App } from './dashboard';
import { GlobalRulesConfig, Group } from './configs/baseConfig';

if (chrome.storage) {
  chrome.storage.local.get(['isGlobalOpen', 'groupRules', 'selectedNode'], (result) => {
    GlobalRulesConfig.isGlobalOpen = !!result.isGlobalOpen;
    GlobalRulesConfig.groupRules = result.groupRules || [new Group()];
    GlobalRulesConfig.selectedNode = result.selectedNode;

    ReactDOM.render(
      <App />,
      document.getElementById('main')
    );
  });
} else {
  ReactDOM.render(
    <App />,
    document.getElementById('main')
  );
}